package jj.fly.cloud.fiegn;

import feign.hystrix.FallbackFactory;
import jj.fly.cloud.entity.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class HystrixClientFallbackFactory implements FallbackFactory<UserFiegnClient> {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Override
    public UserFiegnClient create(Throwable throwable) {
        logger.info("fallback; reason was: " + throwable.getMessage());
        return new UserFiegnClientWithFactory() {
            @Override
            public User findById(Long id) {
                User user = new User();
                user.setId(-1L);
                return user;
            }
        };
    }
}
